package im.elephas.androfan.util;

import java.util.Date;

public class DateFormater {
	public static String formatDate(String d) {
		long l = Date.parse(d);
		Date date = new Date();
		long diff = (date.getTime() - l) / 1000;
		if (diff < 60) {
			return diff + "秒前";
		}
		diff = diff / 60;
		if (diff < 60) {
			return diff + "分钟前";
		}
		diff = diff / 60;
		if (diff < 24) {
			return diff + "小时前";
		}
		diff = diff / 24;
		if (diff < 30) {
			return diff + "天前";
		}
		diff = diff / 30;
		if (diff < 12) {
			return diff + "月前";
		}
		return diff / 12 + "年前";
	}
}
